import axios from 'axios'
export function request(config) {
    // 1.创建axios的实例
    const instance = axios.create({
        baseURL: 'http://192.168.3.103/',
        timeout: 50000,
        headers: {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer app-XWceXiv17ELvyAt6SEl6MCkO'
          }
    })
    instance.interceptors.request.use(config => {
        return config
    }, err => {
        console.log('请求拦截err: ' + err, 456);
    })
    instance.interceptors.response.use(response  => {
        // console.log(res,123)
        return res.data
    }, err => {
        console.log('响应拦截err: ' + err, 123);
        if (err.response.status != 404) {
            console.log('登录状态已过期，您可以继续留在该页面，或者重新登录')
        } else {
            console.log('网络错误')
        }
    })
    return instance(config)
}
